< previous page page_273 next page >

Page 273
called ComputeControlSize that returns the size of a MonthView with the specified number of rows and columns, as shown in the following example:
Dim sngWidth As Single, sngHeight As Single
MonthView1.ComputeControlSize 4, 2, sngWidth, sngHeight
Debug.Print "New control dimensions: " & sngWidth, sngHeight
note.gif The numbers returned by ComputeControlSize are in the units of the form's ScaleMode property (twips by default). square.gif

The preceding code sample calls the ComputeControlSize method to determine the size of a 4×2 MonthView control. The resulting height and width are returned via output parameters to the variables sngWidth and sngHeight.
Working with Values
So far, you have seen how to control the display behavior of the MonthView control. However, to do anything useful with the control, you need a way to determine and set the current date. The main property that you use to do so is the Value property. You can use the Value property to return or set the current date of a month view, as in the following examples:
MonthView1.Value = #01/03/1943#
MonthView1.Value = "7/19/75 2:34:00 PM"
MonthView1.Value = Now
Debug.Print "The Selected date is " & MonthView1.Value
note.gif You can control the range of valid dates by setting the MinDate and MaxDate properties of the control. square.gif

Although the Value property always uses the Visual Basic Date data type, the MonthView control includes several additional properties that represent different parts of the current date value:
MonthThe selected month of the year (1 through 12)
DayThe day of the selected month (1 through 31)
YearThe selected year (for example, 1998)
WeekThe selected week of the year (1 through 52)
Each of the preceding properties is automatically updated when the Value property changes, and vice versa. You can assign or read integer values to these properties to work with just the information you want.
Although the MonthView control's Value property always has only one value, you can set some properties that allow users to select multiple consecutive days on the calendar. By setting the MultiSelect property to True, the users can click and drag to select a range of days, as shown in Figure 12.23.
If you set the MultiSelect property to True, use the SelStart and SelEnd properties to determine the selected date range.

 
< previous page page_273 next page >